package org.rohmh.user.service;

import java.util.List;


import org.rohmh.user.domain.Member;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PreFilter;
import org.springframework.transaction.annotation.Transactional;

@PreAuthorize("hasRole('ROLE_USER') or hasRole('ROLE_ADMIN')")
public interface MemberService {

    @PostFilter("filterObject.email == principal.username or hasRole('ROLE_ADMIN')")
    List<Member> findAll();

    @PreAuthorize("hasRole('ROLE_ADMIN')")
    List<Member> findByLastName(String lastName);

    
    // @PreAuthorize("hasRole('ROLE_ADMIN')")
    @Transactional
    void persist(Member entity);

    @PreFilter("filterObject.email == principal.username")
    @Transactional
    void merge(Member entity);


    @PreAuthorize("hasRole('ROLE_ADMIN')")
    @Transactional
    void remove(Member entity);

    @PreAuthorize("hasRole('ROLE_ADMIN')")
    @Transactional
    void mergedRemove(Member entity);
    
    Member find(Long id);
}
